package data.connector.rippling.client;

import data.connector.rippling.oauth.AuthService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import reactor.core.publisher.Mono;

/**
 *
 * @author Alex bob(https://github.com/vnobo)
 * @date Created by 2020/3/25
 */
@Service
@RequiredArgsConstructor
public class ClientParamsUtil {

    private final AuthService authService;

    public Mono<MultiValueMap<String, String>> authQueryParams(Integer tenantId) {
        return this.authService.getToken(tenantId)
                .map(token -> {
                    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
                    params.set("access_token", token);
                    return params;
                });
    }
}
